package com.jy.rhin.infra.cda;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
 * @author WeiQ
 * @date 2023/3/27 14:02
 * 值域与编码系统标识符映射
 */
@Getter
public enum EBianMa2ZhiYu {
    /**
     * 值域与编码系统标识符映射
     * name()  对应值域标识符
     */
    //todo 添加其他的值域与编码系统的映射关系
    CV08_50_002("CV08.50.002", "2.16.156.10011.2.3.1.211", "药物剂型代码表"),
    CV07_10_001("CV07.10.001", "2.16.156.10011.2.3.1.196", "门诊费用分类代码表"),
    CV07_10_003("CV07.10.003", "2.16.156.10011.2.3.1.197", "医疗费用来源类别代码表"),
    CV07_10_004("CV07.10.004", "2.16.156.10011.2.3.1.198", "医疗费用结算方式代码表"),
    GB_T_2261_1("GB/T 2261.1", "2.16.156.10011.2.3.3.4", "生理性别代码表"),
    GB_T_2261_2("GB/T 2261.2", "2.16.156.10011.2.3.3.5", "婚姻状况代码表"),
    ICD_9_CM_3("ICD-9-CM-3", "2.16.156.10011.2.3.3.12", "ICD-9手术编码"),
    ;

    private static Map<String, EBianMa2ZhiYu> cache = new HashMap<>(EBianMa2ZhiYu.values().length);

    static {
        for (EBianMa2ZhiYu value : EBianMa2ZhiYu.values()) {
            cache.put(value.bianMaXTBSF, value);
        }
    }

    EBianMa2ZhiYu(String zhiYuBSF, String bianMaXTBSF, String bianMaXTMS) {
        this.zhiYuBSF = zhiYuBSF;
        this.bianMaXTBSF = bianMaXTBSF;
        this.bianMaXTMS = bianMaXTMS;
    }

    public static String lookup(String bianMaXTBSF) {
        return Optional.ofNullable(cache.get(bianMaXTBSF)).map(EBianMa2ZhiYu::getZhiYuBSF).orElse("");
    }

    /**
     * 值域标识符
     */
    String zhiYuBSF;
    /**
     * 编码系统 标识符
     */
    String bianMaXTBSF;
    /**
     * 编码系统 描述
     */
    String bianMaXTMS;

}
